#ifndef __X_EGLVIEW_H__
#define __X_EGLVIEW_H__

#include <Windows.h>

class xSize
{
public:
    float width;
    float height;

public:
    xSize();
    xSize(float width, float height);
    xSize(const xSize& other);
    xSize& operator= (const xSize& other);
    void setSize(float width, float height);
    bool equals(const xSize& target) const;
};

class xEGLView
{
public:
    xEGLView();
    ~xEGLView();

    virtual bool isOpenGLReady();
    virtual void end();
    virtual void swapBuffers();
    virtual void setViewName(const char *viewName);
    virtual void setFrameSize(float width, float height);

private:
    virtual bool create();
    bool initGL();
    void destroyGL();

public:
    virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);

    HWND getHWnd();
    void resize(int width, int height);
    void centerWindow();

    static xEGLView *sharedOpenGLView();

    virtual const xSize& getFrameSize() const;

private:
    HWND    _hwnd;
    HDC     _hdc;
    HGLRC   _hrc;
    char    _viewName[64];
    xSize   _screenSize;
};

#endif // __X_EGLVIEW_H__